using UnityEngine;
using System.Collections;

public class SpecialBlock : MonoBehaviour {
public GameObject thePrefab;
public float WaitTime = 0.1f;
	
void OnTriggerEnter(Collider d)
{
	if (d.gameObject.tag == "kulka"){

				//yield WaitForSeconds(WaitTime);
			//saving colors
			/*	KlocekColor KolorScript;
				KolorScript = GetComponent("KlocekColor") as KlocekColor;
				Color TempKolor = KolorScript.Kolor;
				Color TempKolorStrzlka = KolorScript.KolorStrzalka;
			*/
				Color Kolor = renderer.material.GetColor("_ColorKlocek");
				Color KolorStrzalka = renderer.material.GetColor("_ColorStrzalka");
				
			
			//spawning new object
				Destroy(gameObject);
				GameObject NewObject;
				NewObject =  Instantiate(thePrefab, transform.position, transform.rotation) as GameObject;
			//seting color on new object
			/*
				KolorScript = NewObject.GetComponent("KlocekColor") as KlocekColor;
				KolorScript.Kolor = TempKolor;
				KolorScript.KolorStrzalka = TempKolorStrzlka;
				KolorScript.Ready = true;
			*/
			NewObject.renderer.material.SetColor ("_ColorKlocek", Kolor);
			NewObject.renderer.material.SetColor ("_ColorStrzalka", KolorStrzalka);
	}
}
}